#include <Geometry.h>

double
ValidGeometry::getArea(const Length& length, const Length& width) const
{
    return length*width;
}

double
ValidGeometry::getPerimeter(const Length& length, const Length& width) const
{
    return 2*(length+width);
}

bool
ValidGeometry::isValid() const
{
    return true;
}

double
InvalidGeometry::getArea(const Length& length, const Length& width) const
{
    return 0;
}

double
InvalidGeometry::getPerimeter(const Length& length, const Length& width) const
{
    return 0;
}

bool
InvalidGeometry::isValid() const
{
    return false;
}

Geometry *getGeometry(const Length& length, const Length& width)
{
    static ValidGeometry validGeometry;
    static InvalidGeometry invalidGeometry;
    return (length.isValid()&&width.isValid())? ((Geometry *)&validGeometry):((Geometry *)&invalidGeometry);
}


